package testDate;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class dateFormat {
    public static void main(String[] args) throws ParseException {
        DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
        Date d = new Date(121221L);
        System.out.println(d);
        String str = df.format(d);//Thu Jan 01 08:02:01 CST 1970--------->1970-02-01 08:02:01
        System.out.println(str);

        String str2 = "2018-10-8 12:58:52";
        System.out.println(df.parse(str2));//2018-10-8 12:58:52--------->Mon Jan 08 00:58:52 CST 2018
    }
}
